@echo off
echo sum1 a b, return with global variable.
set a=10
set b=20
call :sum1 %a% %b%
echo sum1(%a%,%b%)=%result1%
echo=

echo sum2 a b, return with argument.
set a=10
set b=20
call :sum2 %a% %b% result2
echo sum2(%a%,%b%)=%result2%
echo=

goto :eof

:sum1
set /a result1=%~1 + %~2
goto :eof

:sum2
set /a r3=%~1 + %~2
set "%~3=%r3%"
goto :eof
